<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/8/14 0014
 * Time: 10:59
 */
//  引入SDK加载注册文件
include "../vendor/zoujingli/wechat-php-sdk/include.php";
use think\Config;
use Wechat\Loader;
//key值
const __KEY__ = 'a5226d8d9e3244060883adeb003c6063';
//阿里大鱼配置
const __APPKEY__ = '24592950';
const __SECRETKEY__ = '38209072ecbc55d4923f497d749424e7';
const __FREESIGN__ = '38209072ecbc55d4923f497d749424e7';
//极光推送
const __JAPPKEY__ = 'ac1490121e1fa149edcedb41';
const __MASTER__ = '29e1782c94bd4076b9ebd3ae';

//支付宝配置信息
const __ZFB_APP_ID__ = '2017090708600167';
const __ZFB_SKEY__ = 'MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCjJM9NBr0BQPxS37LtZHmafPt93HnaZzccAamQUvP6kcILsOu/zS4hO8dFtD7MPER6TViEpCUGsjCWMddjAaaDapfdDwoHb0i7qjq1EJcbPsy5dM79BrJGArFgmQe2PAMLSHPOrzH8u5lYxRhmyA0vQrHDJk25YWzH+m4TU3mcN+vqvnRAa6dsaf6LwQAy2X87VXXa/0swYrfvgfiyGcCgP79D4w3++3Ce2IgrRN5IppoKlx5nDdlHYuv3DqzZCMGMxXu2x2F9pRIStObwvNieuUfldKMPejxP9mbmju5yy5ySEq0/DvuoQLi0EZxHejBnDIPC62ndEcOEdi3XM6GhAgMBAAECggEAaolGKmnFEUWLwN6+LJIZaw5E+Qr6M+qFLW/UeCADnVSD4DiXqvflMOSlm9o5zAtrOGa78Fp0p2vDmMFRgyD3yQfZxgzlIrfESnC+x7DezHb1IAKsjMVLs7ZceNVWGOYVos+ceJMl1IH5gOOsrKnlGkC2btbbmLyLWggqy8oONzmsg4zmNV/jY8GKsRsVlZzGUxTDQCwsEXUbbDrvx1VyuVigyQNwf6Rz9bvV/ccM1iJ+8twzciW9HEJRlpRmhWiIsVx/HkmWjh+Lr7qSeTbXX1hroRbFk7Ys/IGTQFHuW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tRCXGz7MuXTO/QayRgKxYJkHtjwDC0hzzq8x/LuZWMUYZsgNL0KxwyZNuWFsx/puE1N5nDfr6r50QGunbGn+i8EAMtl/O1V12v9LMGK374H4shnAoD+/Q+MN/vtwntiIK0TeSKaaCpceZw3ZR2Lr9w6s2QjBjMV7tsdhfaUSErTm8LzYnrlH5XSjD3o8T/Zm5o7ucsuckhKtPw77qEC4tBGcR3owZwyDwutp3RHDhHYt1zOhoQIDAQAB';
//微信配置信息
const __WEIKEY__ ="";//商户平台设置的密匙key值
const __WEIAPPID__ ="";//APPID
const __MCHID__ = "";//商户号

//数组转换json数据
function Rearr($data,$code,$msg)
{
    $arr['data'] = $data;
    $arr['code'] = $code;
    $arr['msg'] = $msg;
    return $arr;
}
//搜索的数据是否为空
function Sel_Y_N_Empty($array){
    if (count($array)==0){
        print_r(json_encode(Rearr('',-102,'success')));exit();
    }
}
//
function field($array,$field)
{
    $i=0;
    foreach ($array as $key => $val)
    {
        foreach ($field as $keys){
            $arr[$i][$keys] = $val[$keys];
        }
        $i.=1;
    }
    return $arr;
}
//获得优惠券
function ShareYHJ($user_id,$state)
{
    $start_time = strtotime(date('Y-m-d',time()));
    $ent_time = strtotime('+10 day',$start_time);
    $youhui = array('user_id'=>$user_id,'start_time'=>$start_time,'end_time'=>$ent_time,'type'=>$state);
    db('youhui') -> insert($youhui);
}
/**
 * 获取微信操作对象
 * @staticvar array $wechat
 * @param type $type
 * @return WechatReceive
 */
function & load_wechat($type = '') {

    static $wechat = array();
    $index = md5(strtolower($type));
    if (!isset($wechat[$index])) {
        $config = config('wechat');
        $config['cachepath'] = CACHE_PATH . 'Data/';
        $wechat[$index] = Loader::get($type, $config);
    }
    return $wechat[$index];
}
